import React from 'react';
import Header from './components/Header';
import Main from './components/Main';
import './index.css';

export default class App extends React.Component {
  state = {
    // ! // 前置：App中删除掉username 和 content
    // ! username: '',
    // ! content: '',
    list: [
      {
        id: 1,
        username: '思聪',
        content: '想你的夜',
      },
      {
        id: 2,
        username: '马芸',
        content: '我对钱不感兴趣',
      },
      {
        id: 3,
        username: '王简林',
        content: '实现一个小目标',
      },
    ],
  };

  handleDelById = (id) => {
    const newList = this.state.list.filter((item) => item.id !== id);
    this.setState({ list: newList });
  };

  render() {
    const { list } = this.state;
    return (
      <div className="app">
        <Header />
        <Main list={list} handleDelById={this.handleDelById} />
      </div>
    );
  }
}
